03. Intro to Computer Hardware

02 L Intro To Comp HW V1 RENDER V1

Compilers and Optimization

As mentioned in the video, a C++ compiler rewrites your code into binary instructions. Many compilers will try to optimize code for you. These optimizations aim to

  • make the code run faster,
  • use less memory, or
  • consume less electric power.

Compilers can be quite good at optimizing as they write your C++ code into machine code; however, when running the same code through different compilers, you might find that the slowest parts of your code are not the same in each case. Hence, it's important to find the weak spots by actually measuring how long it takes to execute or how many resources the code uses. You'll learn more about measuring your code later in the lesson.

Hardware Limitations

Hardware can put limitations on your programs and lead to code inefficiencies.

In embedded systems engineering, you might not always be working with the newest and most powerful computer processors. A typical example would be trigonometric functions. Some computer architectures might use relatively slow software approximations for a sine function rather than using the arithmetic/logic unit. If you can use an approximation that runs directly on the CPU's arithmetic/logic unit, you might get your code to run faster.

Hardware Quiz

QUIZ QUESTION::

Match the Hardware Parts with its Purpose

ANSWER CHOICES:



Hardware

Purpose

Responsible for carrying out the instructions in your code

Carries out the instructions in your code and resolves mathematical equations

Used to temporarily store information about your program

Resolves mathematical and boolean equations

SOLUTION:

Hardware

Purpose

Responsible for carrying out the instructions in your code

Carries out the instructions in your code and resolves mathematical equations

Used to temporarily store information about your program

Resolves mathematical and boolean equations

C++ Demonstrations

This lesson contains a series of demonstrations showing how C++ manages memory. You'll see in the next part that these demonstrations are embedded into the classroom.

Each demonstration is contained in a separate folder with a set of instructions and code. The next section gives more details about how you will run the demonstrations.